#include "Common.fx"

//--------------------------------------
struct a2v {
	a2vGenerateBasic basic;
};

struct v2f {
	v2fGenerateBasic basic;
};

const float4 g_DepthRange = float4(0.25, 0.5, 0.75, 1);

//--------------------------------------
v2f vsMain(a2v input) {
	
	v2f output;
	
	GenerateBasicVertexProcess(output.basic, input.basic);
	
	return output;
}

//--------------------------------------
f2fb psMain(v2f input) {

	f2fb output;
	
	//GenerateBasicFragmentProcess(output.c0, input.basic);
	
	float depth = input.basic.lsPos.z + g_ShadowMapBias;
	
	if(input.basic.lsPos.z < g_DepthRange[0]) {
	
		output.c0 = float4(depth, 1, 1, 1);
	
	} else if(input.basic.lsPos.z < g_DepthRange[1]) {
	
		output.c0 = float4(1, depth, 1, 1);
	
	} else if(input.basic.lsPos.z < g_DepthRange[2]) {
	
		output.c0 = float4(1, 1, depth, 1);
		
	} else {
	
		output.c0 = float4(1, 1, 1, depth);
	
	}
	
	return output;
}

//--------------------------------------
technique Generate {

	pass {
	
		AlphaBlendEnable	= true;
		SrcBlend			= one;
		DestBlend			= one;
		BlendOp				= min;
		AlphaTestEnable		= false;
		ZEnable				= false;
		ZWriteEnable		= false;
		//CullMode			= CW;
		
		VertexShader		= compile vs_3_0 vsMain();
		PixelShader			= compile ps_3_0 psMain();
	}
}

//--------------------------------------